#pragma once
#include "IRender.h"
#include "IrrFontManager.h"
/*----------------------------------------
    Irr Forward declarations ::
------------------------------------------*/

namespace irr {
    class IrrlichtDevice;
    namespace video { 
        class IVideoDriver;
        class SColorf;
    };
    namespace gui {
        class IGUIFont;
        class CGUITTFont;
        class CGUITTFace;
    };
};

/**
==================================
Irrlicht Engine Rendering BackEnd
Version 1.3.1
==================================
*/
class IrrRender : public IRender
{
public:
    IrrRender(void);
    /** Init the backend */
    int Init( const ViewSettings &settings  );
    /** Clean up */
	void Shutdown();
    /** Get Renderer name */
    Renderer_t GetName();
    /** Set display name */
    void SetTitle(const std::string &title );
    /** Call a function on a window close event */
    void OnCloseEvent( OnCloseEventFuncPtr func ) { m_OnCloseEvent = func; };

    /** Draw an image */
	void DrawImage( Image *im, int x, int y);
    /** Draw an image at a set size, if repeat the the image repeats, else it stretchs */
    void DrawImage( Image *im, int x, int y, float width, float height, bool repeat=true);
    /** Draw an image which contains subimages */
    void DrawSubImage( Image *im, int x, int y, int row, int col);

    /** Draw a String */
    void DrawString( int x, int y, const char *s,...);
    /** Set a font type */
    void SetFont( const std::string &font );
    /** Draw an empty rect */
	void DrawRect( int x, int y, int w, int h );
    /** Draw a line */
    void DrawLine( const Vector3f &p1, const Vector3f &p2 );
	/** Fill in a rect */
    void FillRect( int x, int y, int w, int h );
    /** Fill in a rotated rect */
	void FillRectRotate(int x, int y, int w, int h, double rotation);

    /** Draw an empty circle */
    void DrawCircle( float radius, int x, int y);
    /** Fill in a circle */
    void FillCircle( float radius, int x, int y);
    /** get a chars height */
    int GetTextHeight(char);
    /** Get a chars width */
    int GetTextWidth(char);

    /** Set the current color */
	void  SetColor( float r, float g, float b, float a=1);
    void  SetColor(Vector4f c);
    /** Get the current color */
    Vector4f GetColor();
    /** Apply a color effect */
	void  SetColorEffect( float r, float g, float b, float a=1);
    void  SetColorEffect(Vector4f c);
    /** Get the color effect color */
    Vector4f GetColorEffect();
    /** Setup for this frames render */
	void PreRender();
    /** Clean up */
	void PostRender();

    /** Enable fog */
    void EnableFog();
    /** Disable fog */
    void DisableFog();
    /** Set the fog density */
    void SetFogDensity(float density);
    /** Set the fog color */
    void ChangeFogColor(float r, float g, float b, float a=1);
    void ChangeFogColor(Vector4f);
    /** Get the fog color */
    Vector4f GetFogColor();

    /*----------------------------------------------------
        Camera
    ----------------------------------------------------*/
    //ICamera* GetCamera();
    //void SetCamera( ICamera* c );

private:
    /** Check to see if this is a valid display mode */
    bool ValidDisplayMode( irr::core::dimension2d<int> &d, int b );

    Renderer_t                      m_renderer;         // RenderingEngine
    OnCloseEventFuncPtr             m_OnCloseEvent;     // function pointer to a close event
    
    irr::video::IVideoDriver*       m_IrrVideo;         // Irr Video component;

    //irr::gui::IGUIFont*             m_font;          // font
    IrrFontManager                  m_fontMng;          // font Manger
    irr::video::SColorf*            m_currentColor;     // current color

public:
     ~IrrRender(void);
};
